/* 
	该文件用于：提供用户临时标识
*/
//引入uuid
import {v4} from 'uuid'

//getUserTempId用于提供一个用户临时标识
export function getUserTempId(){
	//尝试从localStorage中获取之前存进去的userTempId
	let userTempId = localStorage.getItem('userTempId')
	//判断
	if(userTempId){
		return userTempId
	}
	//没有
	else{
		//生成一个新的标识
		let newUserTempId = v4()
		localStorage.setItem('userTempId',newUserTempId)
		return newUserTempId
	}
}
//saveToken用于把token存入localStorage
export function saveToken(token){
	localStorage.setItem('token',token)
}

export function getToken(){
	return localStorage.getItem('token')
}

export function deleteToken(){
	localStorage.removeItem('token')
}